#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QtMath>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    if (ui) {
        delete ui;
        ui = nullptr;
    }
}

void Widget::on_pushButtonLeft_clicked()
{
    ui->lineEdit->setAlignment(Qt::AlignLeft);
}

void Widget::on_pushButtonCenter_clicked()
{
    ui->lineEdit->setAlignment(Qt::AlignCenter);
}

void Widget::on_pushButtonRight_clicked()
{
    ui->lineEdit->setAlignment(Qt::AlignRight);
}

void Widget::on_pushButtonBold_clicked(bool checked)
{
    QFont font = ui->lineEdit->font();
    font.setBold(checked);
    ui->lineEdit->setFont(font);
}

void Widget::on_pushButtonItalic_clicked(bool checked)
{
    QFont font = ui->lineEdit->font();
    font.setItalic(checked);
    ui->lineEdit->setFont(font);
}

void Widget::on_pushButtonUnder_clicked(bool checked)
{
    QFont font = ui->lineEdit->font();
    font.setUnderline(checked);
    ui->lineEdit->setFont(font);
}

void Widget::on_checkBoxReadonly_clicked(bool checked)
{
    ui->lineEdit->setReadOnly(checked);
}

void Widget::on_checkBoxEnabled_clicked(bool checked)
{
    ui->lineEdit->setEnabled(checked);
}

void Widget::on_checkBoxClear_clicked(bool checked)
{
    ui->lineEdit->setClearButtonEnabled(checked);
}

void Widget::on_radioButtonBlack_clicked()
{
    QPalette plet = ui->lineEdit->palette();
    plet.setColor(QPalette::Text, Qt::black);
    ui->lineEdit->setPalette(plet);
}

void Widget::on_radioButtonRed_clicked()
{
    QPalette plet = ui->lineEdit->palette();
    plet.setColor(QPalette::Text, Qt::red);
    ui->lineEdit->setPalette(plet);
}

void Widget::on_radioButtonBlue_clicked()
{
    QPalette plet = ui->lineEdit->palette();
    plet.setColor(QPalette::Text, Qt::blue);
    ui->lineEdit->setPalette(plet);
}

